#define VER_MAJOR                   3
#define VER_MINOR                   0
#define VER_PATCH                   0
#define VER_SPECIAL                 "Final"

#define BLOCKSIZE                   1024
#define BLOCKSIZE_BITS              8
#define MAXNAME                     15

#define DIRECTBLOCKS                12

#define BLOCKINFOSIZE               5*sizeof(int)

#define MIN(a,b)                    (((a)<(b))?(a):(b))

#define JOURNAL_NONE                0
#define JOURNAL_LOGGING             1
#define JOURNAL_WRITING             2

#define JOURNAL_OP_NONE             0
#define JOURNAL_OP_WRITEFILE        1
#define JOURNAL_OP_SETATTR          2

#define BLOCK_DEVICE                0
#define BLOCK_JOURNAL_STATE         1
#define BLOCK_JOURNAL_DATA          2
#define BLOCK_INODE_LIST            3

#define VVSFS_IOCTL_DECRYPT         _IOR('v', 0, struct vvsfs_ioctl *)
#define VVSFS_IOCTL_ENCRYPT         _IOR('v', 1, struct vvsfs_ioctl *)
#define VVSFS_IOCTL_RESIZE          _IOR('v', 2, struct vvsfs_ioctl *)

#define VVSFS_MOUNT_FLAG_ENCRYPT    (1 << 0)
#define VVSFS_MOUNT_FLAG_COMPRESS   (1 << 1)
#define VVSFS_MOUNT_FLAG_SSDWRITE   (1 << 2)

#define VVSFS_FLAG_ISEMPTY          (1 << 0)
#define VVSFS_FLAG_ENCRYPT          (1 << 1)

#define VVSFS_IFLAG_ISUSED          (1 << 0)
#define VVSFS_IFLAG_COMPRESS        (1 << 1)

#define HEADER_IMAGES "                                                 _          _ \n" \
                      "                                                | |        (_)\n" \
                      "                                              __| |_ __ ___ _ \n" \
                      " ██▒   █▓ ██▒   █▓  ██████   █████▒ ██████   / _` | '__/ _ \\ |\n" \
                      "▓██░   █▒▓██░   █▒▒██    ▒ ▓██   ▒▒██    ▒  | (_| | | |  __/ |\n" \
                      " ▓██  █▒░ ▓██  █▒░░ ▓██▄   ▒████ ░░ ▓██▄     \\__,_|_|  \\___|_|\n" \
                      "  ▒██ █░░  ▒██ █░░  ▒   ██▒░▓█▒  ░  ▒   ██▒  %s\n" \
                      "   ▒▀█░     ▒▀█░  ▒██████▒▒░▒█░   ▒██████▒▒  COMP3300 Assignment 2\n" \
                      "   ░ ▐░     ░ ▐░  ▒ ▒▓▒ ▒ ░ ▒ ░   ▒ ▒▓▒ ▒ ░  Version : %d.%d.%d %s\n" \
                      "   ░ ░░     ░ ░░  ░ ░▒  ░ ░ ░     ░ ░▒  ░ ░   Author : Eric McCreath\n" \
                      "     ░░       ░░  ░  ░  ░   ░ ░   ░  ░  ░              Saki Tojo\n" \
                      "      ░        ░        ░               ░              Jerry Mayazure\n" \
                      "     ░        ░                               Thanks : fzyz999\n" \
                      "This program comes with ABSOLUTELY NO WARRANTY;\n" \
                      "This is free software, and you are welcome to redistribute it\n" \
                      "under certain conditions;\n\n"
#define PROC_ITEM_HEADER    "%s : "

#define true 1
#define false 0

#ifndef uint
#define uint unsigned int
#endif
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint8_t
#define uint8_t  unsigned char
#endif

struct vvsfs_device_block {
    uint device_size;
    uint block_size;
    uint block_count;
    uint inode_block_count;
    uint last_used_block;
};

struct vvsfs_inode {
    uint flag;          //Inode flag.
    uint count;         //Inode reference count.
    uint block;         //Pointed block number.
    uint uid;           //User id.
    uint gid;           //Group id.
    uint mode;          //Execution mode.
    uint size;          //File size.
    uint c_size;        //Compression size.
    uint time_create;   //Time - Creation.
    uint time_modify;   //Time - Modification.
    uint time_access;   //Time - Access.
};

struct vvsfs_block {
    int flag;
    int hash;
    int size;
    int e_size;
    int count;
    char data[];
};

struct vvsfs_dir_entry {
    int inode_number;
    int name_size;
    char name[];
};

struct vvsfs_ioctl {
    char key[32];
    int file_size;
};

struct vvsfs_file_private {
    char *map_data;
};

struct vvsfs_journal_state {
    uint state;
    uint file_operation;
    uint inode_number;
    struct vvsfs_inode inode;
};
